package cn.xuqiudong.rpc.cluster.balance;

import cn.xuqiudong.rpc.common.model.Invoker;
import cn.xuqiudong.rpc.common.model.XqdUrl;

import java.util.List;
import java.util.Random;

/**
 * 描述: 随机的负载均衡策略
 * @author Vic.xu
 * @date 2022-02-23 10:59
 */
public class RandomLoadBalance implements LoadBalance{

    @Override
    public XqdUrl doSelect(List<XqdUrl> urls, Invoker invoker) {
        int index = new Random().nextInt(urls.size());
        return urls.get(index);
    }
}
